package org.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.domain.Question;

import java.util.List;

@Mapper
public interface QuestionDao extends BaseMapper<Question> {

    @Select("select type from question_type where question_id = #{questionId}")
    List<String> getTypeByQuestionId(int questionId);

    @Delete("delete from question_type where question_id = #{questionId}")
    int deleteTypeByQuestionId(int questionId);

    int insertQuestionType(@Param("questionId") int questionId,@Param("types") List<String> types);

    @Select("SELECT DISTINCT question_id FROM question_type WHERE TYPE LIKE #{type}")
    List<Integer> getQuestionIdByType(@Param("type") String type);

}
